<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes"/>

  <xsl:template match="/">

    <html>
      <head>
        <title>Message Testing Service Report</title>
      </head>
      <style type="text/css">
        Body
        {
        FONT-SIZE: 8pt;
        FONT-FAMILY: Verdana,Arial, sans-serif;
        }
        .Label
        {
        COLOR: #4D4D4D;
        Width: 200px;
        FONT-SIZE: 8pt;
        FONT-WEIGHT: bold;
        FONT-FAMILY: Verdana,Arial, sans-serif;
        }
        H2
        {
        FONT-WEIGHT: bold;
        FONT-SIZE: 14pt;
        COLOR: #3366ff;
        FONT-FAMILY: Verdana,Arial, sans-serif;
        }
        H3
        {
        FONT-WEIGHT: bold;
        FONT-SIZE: 12pt;
        COLOR: #3366ff;
        FONT-FAMILY: Verdana,Arial, sans-serif;
        }
        .button
        {
        border-right: buttonshadow 1px solid;
        border-left: buttonshadow 1px solid;
        border-top: buttonshadow 1px solid;
        border-bottom: buttonshadow 1px solid;
        background: buttonface;
        font:  7pt Verdana,Arial, sans-serif;
        color: #3366ff;
        width: 200px;

        }

        .EventGroup
        {
        border-top: thin 1px solid;
        border-right: thin 1px solid;
        border-left: thin 1px solid;
        border-bottom: thin 1px solid;
        }

      </style>

      <script type="text/javascript">


        function showContent(vThis){

        vParent = vThis.parentNode;
        vSibling = vParent.nextSibling;

        while(vSibling.nodeType==3){
        vSibling = vSibling.nextSibling;
        };
        if(vSibling.style.display == "none")
        {
        vThis.src="img/collapse.gif";
        vThis.alt = "Hide";
        vSibling.style.display="block";
        }else{
        vThis.src="img/expand.gif";
        vThis.alt = "Show";
        vSibling.style.display="none";
        }
        return;

        }

      </script>
      <body>
        <h2>Message Testing Service Report</h2>
        <hr/>
        <div>
          <h3>Message Information</h3>
          <span class="Label">Message TransType:</span> <xsl:value-of select="//MessageValidationInfo/TransType"/>(<xsl:value-of select="//MessageValidationInfo/TransType/@tc"/>)<br />
          <span class="Label">Message TransSubType:</span><xsl:value-of select="//MessageValidationInfo/TransSubType"/>(<xsl:value-of select="//MessageValidationInfo/TransSubType/@tc"/>)<br />
          <span class="Label">Date of Validation:</span><xsl:value-of select="//MessageValidationInfo/TransExeDate"/><br />
          <span class="Label">
            Time of Validation:
          </span><xsl:value-of select="//MessageValidationInfo/TransExeTime"/><br />
        </div>
        <hr/>
        <div>
          <h3>Schema Validation Information</h3>
          <span class="Label">Schema File:</span>
          <xsl:value-of select="//SchemaResponseInfo/SchemaFile"/>
          <br />
          <span class="Label">Schema Validation Elapsed Time:</span>
          <xsl:value-of select="//SchemaResponseInfo/ElapsedTime"/>
          <br />
          <span class="Label">Result:</span>
          <xsl:value-of select="//SchemaResults/TransResult/ResultCode"/>
          <br />
          <span class="Label">Total Schema Errors:</span>
          <xsl:value-of select="count(//SchemaResults/ValidationEvent)"/>
          <br />
        </div>

        <h4>
          <input id="Button1" class="Button" type="button" value="Show/Hide Failed Schema Events" onclick="showContent(this);"/>
        </h4>
        <div id="divSchemaEvents" style="display:none;">
          <div class="EventGroup">
            <xsl:for-each select="//SchemaResults/ValidationEvent">
              <span class="Label">Validation Event:</span>
              <xsl:value-of select="./@id"/>
              <br />
              <span class="Label">Result:</span>
              <xsl:value-of select="./TransResult/ResultCode"/>
              <br />
              <span class="Label">Description:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoDesc"/>
              <br />
              <span class="Label">Source:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSource"/>
              <br />
              <br/>
            </xsl:for-each>
          </div>
        </div>

        <hr/>
        <div>
          <h3>Rules Validation Information</h3>
          <span class="Label">
            Rule Validation Elapsed Time:
          </span>
          <xsl:value-of select="//RulesetResponseInfo/ElapsedTime"/>
          <br />
          <span class="Label">Total Rules in RuleSet:</span>
          <xsl:value-of select="//RulesetResponseInfo/TotalRuleSetRules"/>
          <br />
          <span class="Label">
            Total Rules Run:
          </span>
          <xsl:value-of select="//RulesetResponseInfo/TotalRulesRun"/>
          <br />
          <span class="Label">Total Rules Succeeded:</span>
          <xsl:value-of select="//RulesetResponseInfo/TotalSuccessfulRules"/>
          <br />
          <span class="Label">Total Rules Failed:</span>
          <xsl:value-of select="//RulesetResponseInfo/TotalFailedRules"/>
                    <br />
        </div>
        <h4>
          <input id="Button1" class="Button" type="button" value="Show/Hide Successful Rule Events" onclick="showContent(this);"/>
        </h4>
        <div id="div1" style="display:none;">
          <div class="EventGroup">
            <xsl:for-each select="//RulesetResponse/RuleEvent[TransResult/ResultCode/@tc=1]">
              <span class="Label">Rule Event:</span>
              <xsl:value-of select="./@id"/>
              <br />
              <span class="Label">Description:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoDesc"/>
              <br/>
              <span class="Label">Severity:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSeverity"/>
              <br/>
              <span class="Label">
                Message Code:
              </span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSysMessageCode"/>
              <br/>
              <span class="Label">Source:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSource"/>
              <br/>
              <br/>
            </xsl:for-each>
          </div>
        </div>
        <h4>
          <input id="Button1" class="Button" type="button" value="Show/Hide Failed Rule Events" onclick="showContent(this);"/>
        </h4>
        <div id="div1" style="display:none;">
          <div class="EventGroup">
            <h3>Severity: Error</h3>
            <br/>
            <xsl:for-each select="//RulesetResponse/RuleEvent[TransResult/ResultCode/@tc=5 and TransResult/ResultInfo/ResultInfoSeverity = 'Error'] ">
              <span class="Label">Rule Event:</span>
              <xsl:value-of select="./@id"/>
              <br />
              <span class="Label">Description:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoDesc"/>
              <br/>
              <span class="Label">Severity:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSeverity"/>
              <br/>
              <span class="Label">
                Message Code:
              </span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSysMessageCode"/>
              <br/>
              <span class="Label">Source:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSource"/>
              <br/>
              <br/>
            </xsl:for-each>
          </div>
          <br/>
          <div class="EventGroup">
            <h3>Severity: Warning</h3>
            <br/>
            <xsl:for-each select="//RulesetResponse/RuleEvent[TransResult/ResultCode/@tc=5 and TransResult/ResultInfo/ResultInfoSeverity != 'Error'] ">
              <span class="Label">Rule Event:</span>
              <xsl:value-of select="./@id"/>
              <br />
              <span class="Label">Description:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoDesc"/>
              <br/>
              <span class="Label">Severity:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSeverity"/>
              <br/>
              <span class="Label">
                Message Code:
              </span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSysMessageCode"/>
              <br/>
              <span class="Label">Source:</span>
              <xsl:value-of select="./TransResult/ResultInfo/ResultInfoSource"/>
              <br/>
              <br/>
            </xsl:for-each>
          </div>
        </div>

      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>